package com.web.controller;

import com.exception.RequestLimitException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * Created with IntelliJ IDEA.
 * User: lxf
 * Date: 2016/4/18
 * Time: 9:43
 * To change this template use File | Settings | File Templates.
 */
@ControllerAdvice(basePackages = {"com.web.controller"}, basePackageClasses = {com.web.IndexController.class})
public class ExceptionController {


    @ExceptionHandler(NullPointerException.class)
    public String nullPointerException() {
        return "test";
    }


    @ExceptionHandler(RequestLimitException.class)
    public String requestLimitException(Model model) {
        model.addAttribute("errorMsg", "请求过于频繁,超出限制!");
        return "error";
    }

}
